﻿using System.Threading.Tasks;
using XYS.Service.Core.Util;
using XYS.Service.Core.Util.Helper;

namespace XYS.Core.Util;

public static partial class Extention
{
    /// <summary>
    /// 什么都不做,仅仅是消除警告
    /// </summary>
    /// <param name="task"></param>
    public static void DoNotAwait(this Task task) { }

    /// <summary>
    /// 随机延迟
    /// </summary>
    /// <param name="task"></param>
    /// <param name="min"></param>
    /// <param name="max"></param>
    /// <returns></returns>
    public static Task Delay(this Task task, TimeSpan min, TimeSpan max)
    {
        var delayTime = DateTimeHelper.GetRandomDelay(min, max);
        return Task.Delay(delayTime);
    }
}